package cn.wolfcode.luowowo.common.util;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
 * @author 猫教授
 * @date 2019/8/7 19:52
 */
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
//工具类,用于向前端页面响应ajax请求
public class AjaxResult {
    private boolean success=true;
    private String  msg;
    private Object data;
    private int code;//状态码

    public AjaxResult(boolean success, String msg) {
        this.success = success;
        this.msg = msg;
    }

    public AjaxResult(boolean success, String msg, Object data) {
        this.success = success;
        this.msg = msg;
        this.data = data;
    }

    public AjaxResult(boolean success){
        this.success=success;
    }


    public static final AjaxResult SUCCESS =new AjaxResult();

    public static final AjaxResult FAL = new AjaxResult(false);

    public AjaxResult addData(Object data){
        this.data=data;
        return this;
    }
}
